#include "widget.h"
#include "ui_widget.h"

#include <QFileDialog>
#include <QFileInfo>
#include <QDebug>
#include <QDateTime>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    QString path = QFileDialog::getOpenFileName();
    QFileInfo fileinfo(path);

    qDebug() << "文件名为：" << fileinfo.fileName().toUtf8().data();

    qDebug() << "后缀名为：" << fileinfo.suffix();

    qDebug() << "文件大小为：" << fileinfo.size();

    qDebug() << "文件路径为：" << fileinfo.path().toUtf8().data();

    qDebug() << "是否为文件："<< fileinfo.isFile();

    QDateTime time1 = fileinfo.fileTime(QFileDevice::FileBirthTime);
    qDebug() << "创建时间为：" << time1.toString("yyyy-MM-ddhh:mm:ss").toUtf8().data();

    QDateTime time2 = fileinfo.lastModified();
    qDebug() << "最后修改时间为："<< time2.toString("yyyy-MM-ddhh:mm:ss").toUtf8().data();

    qDebug() << "是否为目录：" << fileinfo.isDir();
}
